https://leetcode.cn/problems/the-skyline-problem/submissions/676429352/

class Solution {
public:
	vector<vector<int>> getSkyline(vector<vector<int>>& buildings) {
		vector<vector<int>> res;
		vector<pair<int , int>> height;
		for(auto &b : buildings){
			height.push_back({b[0] , -b[2]});
			height.push_back({b[1] , b[2]});
		}
		sort(height.begin() , height.end());
		multiset<int> st;
		st.insert(0);
		int pre = 0 , cur = 0;
		for(auto &h : height){
			if(h.second < 0){
				st.insert(-h.second);
			}
			else{
				st.erase(st.find(h.second));
			}
			cur = *st.rbegin();
			if(cur != pre){
				res.push_back({h.first , cur});
				pre = cur;
			}
		}
		return res;
	}
};
